using System;
using LambdaGp.Core;

namespace LambdaGp.Operators.Functions
{
    public abstract class BinaryOperator : Operator
    {
        protected BinaryOperator(string name)
            : base(name)
        {
        }
        public override int Arity { get { return 2; } }
        public override Func<double> CompileToFunc(Individual individual, OperatorNode operatorNode)
        {
            Func<double> first = operatorNode.Children[0].CompileToFunc(individual);
            Func<double> second = operatorNode.Children[1].CompileToFunc(individual);
            return CompileBinaryToFunc(individual, first, second);
        }
        protected abstract Func<double> CompileBinaryToFunc(Individual individual, Func<double> first, Func<double> second);
    }
}
